package com.easy.auth.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.easy.auth.domain.Reportlog;
import com.easy.auth.domain.UploadFile;
import com.easy.auth.service.ReportlogService;
import com.easy.common.jdbc.PageInfo;
import com.easy.common.web.FilterUtil;
import com.easy.common.web.PagedList;
import com.easy.common.web.message.DeleteMessage;
import com.easy.common.web.message.Message;
import com.easy.common.web.message.SaveOrEditMessage;

@Controller
@RequestMapping("ReportlogController")
public class ReportlogController {

	@Autowired
	private ReportlogService ReportlogService;

	@RequestMapping("goToReportlogManager")
	public String goToActionManager(String secondMenuId,HttpServletRequest request) {
		request.getSession().setAttribute("secondMenuId", secondMenuId);
		return "DPV/reportlogs";
	}

	/**
	 * 查询全部节点数据
	 * 
	 * @return
	 */
	@RequestMapping("getReportlogList")
	@ResponseBody
	public PagedList<Reportlog> getReportlogList(PageInfo pageInfo) {
		Reportlog reportlog = (Reportlog) FilterUtil.getVO(Reportlog.class,
				pageInfo.getFilterRules());
//		pageInfo.setOrder("desc");
//		pageInfo.setSort("last_modify_time");
		return ReportlogService.getAllReportlogsLike(reportlog, pageInfo);
	}

	
	
	
	/**
	 * 根据oid查询该节点其他数据
	 * 
	 * @return
	 */
	@RequestMapping("findReportlogById")
	@ResponseBody
	public Reportlog findReportlogById(Reportlog Reportlog) {
		return ReportlogService.findReportlogById(Reportlog);
	}

	/**
	 * 保存资源信息
	 * 
	 * @param param
	 * @param request
	 * @return
	 */
	@RequestMapping("saveOrEditReportlog")
	@ResponseBody
	public Message saveTreegridItem(Reportlog Reportlog) {
		int count = ReportlogService.saveReportlog(Reportlog);
		return new SaveOrEditMessage(count);
	}

	/**
	 * 删除资源信息
	 * 
	 * @param param
	 * @param request
	 * @return
	 */
	@RequestMapping("removeReportlog")
	@ResponseBody
	public Message removeTreegridItem(String oids) {
		String[] ids = oids.split("-");
		return new DeleteMessage(ReportlogService.removeReportlogs(ids));
	}

}
